<!doctype html>
<html lang="en">

	<head>
		<meta charset="utf-8" />
		<title>销售终端信息</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />

		<!-- App favicon -->
		<link rel="shortcut icon" href="assets/images/favicon.ico">

		<!-- App css -->
		<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/icons.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/metismenu.min.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css" href="assets/css/custom.css" />
		<!-- layer插件 -->
		<link rel="stylesheet" type="text/css" href="plugins/layer2.4/skin/layer.css" />

		<!-- bootstrap-select -->
		<link rel="stylesheet" type="text/css" href="plugins/bootstrap-select/css/bootstrap-select.min.css" />

		<script src="assets/js/modernizr.min.js"></script>

	</head>

	<body>

		<!-- Begin page -->
		<div id="wrapper">

			<!-- ============================================================== -->
			<!-- 页面内容开始 -->
			<!-- ============================================================== -->

			<!-- Start Page content -->
			<div class="my-content">
				<div class="container-fluid">
					<div class="row">
						<div class="col-md-12">
							<div class="card-box">
								<h4 class="m-t-0 m-b-30 header-title">销售终端信息</h4>

								<form class="form-horizontal" role="form">
									<div class="form-group row">
										<label for="number" class="col-3 col-form-label">销售终端编号</label>
										<div class="col-9">
											<input type="text" class="form-control hidden" id="id" name="id" placeholder="销售终端编号">
											<input type="text" class="form-control" id="number" name="number" placeholder="销售终端编号">
										</div>
									</div>
									<div class="form-group row">
										<label for="name" class="col-3 col-form-label">名称</label>
										<div class="col-9">
											<input type="text" class="form-control" id="name" name="name" placeholder="名称">
										</div>
									</div>
									<div class="form-group row">
										<label for="addr" class="col-3 col-form-label">地址</label>
										<div class="col-9">
											<input type="text" class="form-control" id="addr" name="addr" placeholder="地址">
										</div>
									</div>
									<div class="form-group row">
										<label for="responsible" class="col-3 col-form-label">负责人</label>
										<div class="col-9">
											<select class="selectpicker form-control" id="responsible" name="responsible" title="负责人" data-hide-disabled="ture" data-actions-box="true">
											</select>
										</div>
									</div>
									<div class="form-group row">
										<label for="mobile" class="col-3 col-form-label">手机</label>
										<div class="col-9">
											<input type="text" class="form-control" id="mobile" name="mobile" placeholder="手机">
										</div>
									</div>
									<div class="form-group row">
										<label for="phone" class="col-3 col-form-label">电话</label>
										<div class="col-9">
											<input type="text" class="form-control" id="phone" name="phone" placeholder="电话">
										</div>
									</div>
									<div class="form-group row">
										<label for="email" class="col-3 col-form-label">邮箱</label>
										<div class="col-9">
											<input type="text" class="form-control" id="email" name="email" placeholder="邮箱">
										</div>
									</div>

									<div class="form-group mb-0 justify-content-end row">
										<div class="col-9">
											<button type="submit" class="btn btn-primary waves-effect">提交</button>
											<button type="button" onclick="layer_close()" class="btn btn-danger waves-effect">关闭</button>
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>

				</div>
				<!-- container -->

			</div>

			<!-- ============================================================== -->
			<!-- End Right content here -->
			<!-- ============================================================== -->

		</div>
		<!-- END wrapper -->

		<!-- jQuery  -->
		<script src="assets/js/jquery.min.js"></script>
		<script src="assets/js/bootstrap.bundle.min.js"></script>
		<script src="assets/js/metisMenu.min.js"></script>
		<script src="assets/js/waves.js"></script>
		<script src="assets/js/jquery.slimscroll.js"></script>

		<!-- App js -->
		<script src="assets/js/custom.js" type="text/javascript" charset="utf-8"></script>
		<script src="assets/js/jquery.core.js"></script>
		<script src="assets/js/jquery.app.js"></script>
		<script src="assets/js/custom.js" type="text/javascript" charset="utf-8"></script>

		<!-- 表单验证 -->
		<script src="plugins/jquery.form.js/jquery.form.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="plugins/jquery.validation.1.14.0/jquery.validate.js" type="text/javascript" charset="utf-8"></script>
		<script src="plugins/jquery.validation.1.14.0/validate-methods.js" type="text/javascript" charset="utf-8"></script>
		<script src="plugins/jquery.validation.1.14.0/messages_zh.js" type="text/javascript" charset="utf-8"></script>
		<!-- bootstrap-select -->
		<script src="plugins/bootstrap-select/js/bootstrap-select.js" type="text/javascript" charset="utf-8"></script>

		<!-- layer插件 -->
		<script src="plugins/layer2.4/layer.js" type="text/javascript" charset="utf-8"></script>

		<!-- easyUI -->
		<script src="plugins/jquery-easyUI/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="plugins/jquery-easyUI/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>

		<!-- datatables插件 -->
		<script type="text/javascript">
			$(function() {
				//获取用户列表
				$.ajax({
					type: "post",
					url: URL+'findUserAll',
					async: false,
					dataType: "json",
					success: function(data) {
						for (var i = 0; i < data.length; i++) {
							var options = $('<option value="' + data[i].personId + '">' + data[i].username + '    [id=' + data[i].personId + ']'+ '</option>')
							$("#responsible").append(options);
						}
						$('.selectpicker').selectpicker('refresh');
						$('.selectpicker').selectpicker('render');
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						networkError(XMLHttpRequest, textStatus, errorThrown)
					}
				});

				//表单验证
				$("form").validate({
					rules: {
						number:{
							number: true,
							required:true
						},
						name:{
							required:true,	
						},
						responsible:{
							required:true,	
						},
						mobile: {
							required:true,
							number: true
						},
                        phone: {
							number: true
						},
                        email: {
							required:true,
							email: true
						}
					},
					onkeyup: false,
					focusCleanup: true,
					success: "valid",
					submitHandler: function(form) {
						var index = parent.layer.getFrameIndex(window.name);
						$(form).ajaxSubmit({
							type: "POST",
							url: URL+"salesTerminal",
							success: function(data) {
								parent.layer.msg('修改成功!', {
									icon: 1,
									time: 1000
								});
								setTimeout(function() {
									parent.$(".btn-refresh").click();
									parent.layer.close(index);
								}, 1000);

							},
							error: function(XMLHttpRequest, textStatus, errorThrown) {
								networkError(XMLHttpRequest, textStatus, errorThrown)
							}
						});
					}
				});
				code = get_code()
					//把参数回填
				$.ajax({
					type: "get",
					url: URL+'salesTerminal/id?id=' + code,
					async: false,
					dataType: "json",
					success: function(data) {
						data = data.object
						$("form").form('load', data);
						$('#responsible').selectpicker('val', data.userId);
						$('.selectpicker').selectpicker('refresh');
						$('.selectpicker').selectpicker('render');
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						networkError(XMLHttpRequest, textStatus, errorThrown)
					}
				});
			});
		</script>

	</body>

</html>